package com.zhuss.core.company;

import com.zhuss.bean.bo.core.company.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * 公司操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("companyOperateService")
public class CompanyOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("companyCreate")
	private Processor<Object, CreateCompanyBo> companyCreate;

	@Autowired
	@Qualifier("companyUpdate")
	private Processor<Object, UpdateCompanyBo> companyUpdate;

	@Autowired
	@Qualifier("companyDelete")
	private Processor<Object, DeleteCompanyBo> companyDelete;

	@Autowired
	@Qualifier("deptCreate")
	private Processor<Object, CreateDeptBo> deptCreate;

	@Autowired
	@Qualifier("deptUpdate")
	private Processor<Object, UpdateDeptBo> deptUpdate;

	@Autowired
	@Qualifier("deptDelete")
	private Processor<Object, DeleteDeptBo> deptDelete;

	@Autowired
	@Qualifier("companyStart")
	private Processor<Object, StartCompanyBo> companyStart;

	@Autowired
	@Qualifier("companyStop")
	private Processor<Object, StopCompanyBo> companyStop;


	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateCompanyBo bo = (CreateCompanyBo) param;

		companyCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateCompanyBo bo = (UpdateCompanyBo) param;

		companyUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteCompanyBo bo = (DeleteCompanyBo) param;

		companyDelete.process(bo);

		return null;
	}


	/**
	 * 创建部门
	 */
    @Transactional(rollbackFor = Exception.class)
	public Void createDept(Object param) throws DzcxException {

		CreateDeptBo bo = (CreateDeptBo) param;

		deptCreate.process(bo);

		return null;
	}

	/**
	 * 修改部门
	 */
    @Transactional(rollbackFor = Exception.class)
    public Void updateDept(Object param) throws DzcxException {

		UpdateDeptBo bo = (UpdateDeptBo) param;

		deptUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除部门
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void deleteDept(Object param) throws DzcxException {

		DeleteDeptBo bo = (DeleteDeptBo) param;

		deptDelete.process(bo);

		return null;
	}

	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {

		StartCompanyBo bo = (StartCompanyBo) param;

		companyStart.process(bo);

		return null;
	}

	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {

		StopCompanyBo bo = (StopCompanyBo) param;

		companyStop.process(bo);

		return null;
	}



}

